package com.atguigu.tingshu.user.client;

import com.atguigu.tingshu.common.cache.GuiGuCache;
import com.atguigu.tingshu.model.user.UserInfo;
import com.atguigu.tingshu.user.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 用户信息内部调用的接口控制层
 *
 * @author Taeyang
 * @date 2025/4/29
 */
@RestController
@RequestMapping("/client/user/userInfo")
public class UserClientController {

    private final UserInfoService userInfoService;

    @Autowired
    public UserClientController(UserInfoService userInfoService) {
        this.userInfoService = userInfoService;
    }

    /**
     * 查询用户的详细信息
     * @param userId
     * @return
     */
    @GuiGuCache(prefix = "getUserInfo:")
    @GetMapping("/getUserInfo/{userId}")
    public UserInfo getUserInfo(@PathVariable("userId") Long userId) {
        return userInfoService.getById(userId);
    }

    /**
     * 查询用户购买专辑的状态
     *
     * @param userId
     * @param albumId
     * @return
     */
    @GetMapping("/getUserAlbumPaidStatus/{userId}/{albumId}")
    public Boolean getUserAlbumPaidStatus(@PathVariable("userId") Long userId, @PathVariable("albumId") Long albumId) {
        return userInfoService.getUserAlbumPaidStatus(userId, albumId);
    }

    /**
     * 查询用户购买的专辑的声音map集合
     * @param userId
     * @param albumId
     * @return
     */
    @GetMapping("/getUserTrackPaidMap/{userId}/{albumId}")
    public Map<String, Object> getUserTrackPaidMap(@PathVariable("userId") Long userId, @PathVariable("albumId") Long albumId) {
        return userInfoService.getUserTrackPaidMap(userId, albumId);
    }

}
